package com.lzy.product.service.impl;

import com.lzy.framework.core.utils.DozerUtils;
import com.lzy.product.dao.ProductYieldRatioMapperExt;
import com.lzy.product.dtos.ProductYieldRatioDto;
import com.lzy.product.entity.ProductYieldRatio;
import com.lzy.product.service.ProductYieldRatioService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by WIN7 on 2017/12/28.
 */
@Service
public class ProductYieldRatioServiceImpl implements ProductYieldRatioService {

    @Autowired
    ProductYieldRatioMapperExt productYieldRatioMapperExt;

    @Override
    public Long insert(ProductYieldRatioDto dto) {
        return productYieldRatioMapperExt.insertSelective(DozerUtils.map(dto, ProductYieldRatio.class))>0?1L:null;
    }

    @Override
    public Boolean update(ProductYieldRatioDto dto) {
        return productYieldRatioMapperExt.updateByPrimaryKeySelective(DozerUtils.map(dto,ProductYieldRatio.class))>0;
    }

    @Override
    public Boolean delete(Long id) {
        return productYieldRatioMapperExt.deleteByPrimaryKey(id)>0;
    }

    @Override
    public Boolean remove(Long id) {
        return null;
    }

    @Override
    public ProductYieldRatioDto findById(Long id) {
        return DozerUtils.map(productYieldRatioMapperExt.selectByPrimaryKey(id),ProductYieldRatioDto.class);
    }

    @Override
    public List<ProductYieldRatioDto> query(ProductYieldRatioDto dto) {
        return null;
    }

    @Override
    public List<ProductYieldRatioDto> queryListByProductId(Long productId) {
        return productYieldRatioMapperExt.queryListByProductId(productId);
    }

    @Override
    public Integer delByProductId(Long productId) {
        return productYieldRatioMapperExt.delByProductId(productId);
    }
}
